package com.ngc.mall.common.configure.interceptor;


import com.ngc.mall.common.configure.token.AuthorizeVerifyResolver;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 登录拦截器 (pc)
 */
public class AuthInterceptor  implements HandlerInterceptor {

    @Resource
    private AuthorizeVerifyResolver authorizeVerifyResolver;
    /**
     * 处理前
     * @param request
     * @param response
     * @param handler
     * @return
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler){
                System.out.println("我过来了");
        return authorizeVerifyResolver.handleLogin(request,response);
//        System.out.println("我过来了");
//        return true;
    }

    /**
     * 处理中
     * @param request
     * @param response
     * @param handler
     * @param modelAndView
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView){
        System.out.println("postHandle");
    }

    /**
     * 完成
     * @param request
     * @param response
     * @param handler
     * @param ex
     */
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex){
        System.out.println("afterCompletion");
    }
}
